package com.example.detectivedemo.domain.generic;

import java.io.Serializable;
import java.util.Date;

/**
 * 通用实体类
 * 作为所有业务实体的基础类，提供通用属性和方法
 */
public abstract class GenericEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    
    private String id;
    private Date createTime;
    private Date updateTime;
    private boolean deleted;
    
    // 构造函数
    public GenericEntity() {
        this.createTime = new Date();
        this.updateTime = new Date();
        this.deleted = false;
    }
    
    // Getter和Setter方法
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public Date getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    
    public Date getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    
    public boolean isDeleted() {
        return deleted;
    }
    
    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        GenericEntity that = (GenericEntity) obj;
        return id != null && id.equals(that.id);
    }
    
    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }
    
    @Override
    public String toString() {
        return getClass().getSimpleName() + "{id='" + id + "'}";
    }
}